import 'dart:async';

import 'package:flutter/material.dart';

/// 切换图片底部白点选中项小部件
class HeroImageSwiperPlugin extends StatelessWidget {
  const HeroImageSwiperPlugin(this.images, this.index, this.reBuild);
  final List<String> images;
  final int index;
  final StreamController<int> reBuild;
  @override
  Widget build(BuildContext context) {
    return StreamBuilder<int>(
      builder: (BuildContext context, AsyncSnapshot<int> data) {
        return Container(
          padding: EdgeInsets.all(20.0),
          child: Row(
            mainAxisAlignment: MainAxisAlignment.center,
            children: List.generate(images.length, (i) {
              return Container(
                margin: EdgeInsets.symmetric(horizontal: 5),
                width: 8.0,
                height: 8.0,
                decoration: BoxDecoration(
                  shape: BoxShape.circle,
                  color: data.data == i ? Colors.white : Colors.white60,
                ),
              );
            }).toList(),
          ),
        );
      },
      initialData: index,
      stream: reBuild.stream,
    );
  }
}
